package com.malbbmsomanager.onlinereports;

import java.util.ArrayList;
import java.util.HashMap;

import com.malbbmsomanagerdemo.R;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class DM_BBM_Customer_Wise_Sales_Report_Online_Adapter extends BaseAdapter {
	// Declare Variables
	Context context;
	LayoutInflater inflater;
	ArrayList<HashMap<String, String>> data;
	TextView CusName, RepDate,InvoiceRef,InvoiceVal,InvoiceTotal;
	
	public DM_BBM_Customer_Wise_Sales_Report_Online_Adapter(Context context,
			ArrayList<HashMap<String, String>> arraylist) {
		this.context = context;
		data = arraylist;
	}

	@Override
	public int getCount() {
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	public View getView(final int position, View convertView, ViewGroup parent) {
		// Declare Variables
		
		inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);


		View itemView = inflater.inflate(R.layout.dm_bbm_customer_wise_sales_report_online_raw,
				parent, false);
		// Get the position from the results
		HashMap<String, String> resultp = new HashMap<String, String>();
		resultp = data.get(position);

		// Locate the TextViews in listview_item.xml
		CusName = (TextView) itemView.findViewById(R.id.record_0);
		RepDate = (TextView) itemView.findViewById(R.id.record_1);
		InvoiceRef = (TextView) itemView.findViewById(R.id.record_2);
		InvoiceVal = (TextView) itemView.findViewById(R.id.record_3);
		InvoiceTotal = (TextView) itemView.findViewById(R.id.record_4);

		// Capture position and set results to the TextViews
		CusName.setText(resultp.get(DM_BBM_Customer_Wise_Sales_Report_Online.Name));
		RepDate.setText(resultp.get(DM_BBM_Customer_Wise_Sales_Report_Online.Date));
		InvoiceRef.setText(resultp.get(DM_BBM_Customer_Wise_Sales_Report_Online.InvoiceNo));
		InvoiceVal.setText(resultp.get(DM_BBM_Customer_Wise_Sales_Report_Online.InvoiceValue));
		InvoiceTotal.setText(resultp.get(DM_BBM_Customer_Wise_Sales_Report_Online.TotalAmt));

		// Capture button clicks on ListView items
		itemView.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// Get the position from the results
				
			}
		});

		return itemView;
	}
}
